<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">新联登统计</ui:define>
    <ui:define name="content">

        <h:form>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix" style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         onstart="PF('doing').show()"
                                         update="@form"/>
                        <p:commandButton value="重置" actionListener="#{newUnionLoginStatBean.onReset()}" icon="fa fa-refresh"
                                         process="@this" update="@form"/>
                        <p:commandButton value="导出" icon="fa fa-download"
                                         ajax="false">
                            <p:dataExporter type="csv" target="statisticRecordDataTable" fileName="union-info" encoding="GBK"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-g ui-fluid" style="padding-top: 30px;">
                <div class="ui-g-12">
                    <div class="ui-g-12 card">
                        <h1>查询条件</h1>
                        <div class="ui-g-1">
                            <p:outputLabel value="时间"/>
                        </div>
                        <div class="ui-g-3">
                            <p:calendar value="#{newUnionLoginStatBean.$.beginDate}"
                                        locale="#{constants:get('LOCALE')}"
                                        styleClass="autoWidthCalendar"
                                        timeZone="#{constants:get('TIME_ZONE')}"
                                        pattern="#{constants:get('DATE_FORMAT')}"/>
                            <span>—</span>
                            <p:calendar value="#{newUnionLoginStatBean.$.endDate}"
                                        locale="#{constants:get('LOCALE')}"
                                        styleClass="autoWidthCalendar"
                                        timeZone="#{constants:get('TIME_ZONE')}"
                                        pattern="#{constants:get('DATE_FORMAT')}"/>
                        </div>
                        <div class="ui-g-1">
                            <p:outputLabel value="平台"/>
                        </div>
                        <div class="ui-g-3">
                            <p:selectOneMenu value="#{newUnionLoginStatBean.$.platform}">
                                <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                <f:selectItem itemLabel="android" itemValue="android"/>
                                <f:selectItem itemLabel="IOS" itemValue="ios"/>
                            </p:selectOneMenu>
                        </div>
                        <div class="ui-g-1">
                            <p:outputLabel value="产品"/>
                        </div>
                        <div class="ui-g-3">
                            <p:selectOneMenu value="#{newUnionLoginStatBean.$.productId}"
                                             filter="true" updateLabel="true" filterMatchMode="contains">
                                <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                <f:selectItems value="#{newUnionLoginStatBean.commProductIds}"
                                               var="product"
                                               itemValue="#{product.productId}" itemLabel="#{product.name}(#{product.productId})"/>
                            </p:selectOneMenu>
                        </div>
                        <div class="ui-g-1">
                            <p:outputLabel value="渠道"/>
                        </div>
                        <div class="ui-g-3">
                            <p:selectOneMenu value="#{newUnionLoginStatBean.$.channel}"
                                             filter="true" updateLabel="true" filterMatchMode="contains">
                                <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                <f:selectItems value="#{newUnionLoginStatBean.commProductChannels}"
                                               var="channel"
                                               itemValue="#{channel.channelCode}" itemLabel="#{channel.channelName}(#{channel.channelCode})"/>
                            </p:selectOneMenu>
                        </div>

                        <div class="ui-g-1">
                            <p:outputLabel value="活动"/>
                        </div>
                        <div class="ui-g-3">
                            <p:selectOneMenu value="#{newUnionLoginStatBean.$.activityId}"
                                             filter="true" updateLabel="true" filterMatchMode="contains">
                                <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                <f:selectItems value="#{newUnionLoginStatBean.productInfos}"
                                               var="info"
                                               itemValue="#{info.id}" itemLabel="#{info.name}(#{info.id})"/>
                            </p:selectOneMenu>
                        </div>

                        <!--<div class="ui-g-1">
                            <p:outputLabel value="所属大产品"/>
                        </div>
                        <div class="ui-g-3">
                            <p:selectOneMenu value="#{newUnionLoginStatBean.$.parentId}"
                                             filter="true" updateLabel="true" filterMatchMode="contains">
                                <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                <f:selectItems
                                        value="#{newUnionLoginStatBean.dictionaries[DictionaryCode.LARGE_COMMON_PRODUCT]}"
                                        var="largeCommProduct"
                                        itemLabel="#{largeCommProduct.name}" itemValue="#{largeCommProduct.value1}"/>
                            </p:selectOneMenu>
                        </div>-->
                    </div>


                    <div class="ui-g-12 card">
                        <p:dataTable id="statisticRecordDataTable"
                                     style="width: 100%;text-align:center"
                                     var="record"
                                     value="#{newUnionLoginStatBean.lazyDataModel}"
                                     rows="#{constants:get('ROWS')}"
                                     lazy="true"
                                     paginator="true"
                                     paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                     rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                     emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                     scrollable="true"
                                     reflow="true"
                                     selection=""
                                     resizableColumns="true">
                            <p:column headerText="时间" style="text-align:center;">
                                <h:outputText value="#{record.createDate}"/>
                            </p:column>
                            <p:column headerText="所属大产品" style="text-align:center;">
                                <h:outputText
                                        value="#{newUnionLoginStatBean.translate(DictionaryCode.LARGE_COMMON_PRODUCT,record.parentId)}"/>
                            </p:column>
                            <p:column headerText="产品" style="text-align:center;">
                                <h:outputText value="#{'全部' eq(record.productName) ? '全部' : newUnionLoginStatBean.translateProduct(record.productName)}"/>
                            </p:column>
                            <p:column headerText="平台" style="text-align:center;">
                                <h:outputText value="#{record.platform}"/>
                            </p:column>
                            <p:column headerText="渠道" style="text-align:center;">
                                <h:outputText value="#{'全部' eq(record.channel) ? '全部' : newUnionLoginStatBean.translateProductChannel(record.channel)}"/>
                            </p:column>
                            <p:column headerText="联登序号" style="text-align:center;">
                                <h:outputText value="#{record.unionLoginType}"/>
                            </p:column>
                            <p:column headerText="联登产品" style="text-align:center;">
                                <h:outputText value="#{newUnionLoginStatBean.translateProductInfoName(record.activity)}"/>
                            </p:column>
                            <p:column headerText="联登成功人数" style="text-align:center;">
                                <h:outputText value="#{record.reqNum}"/>
                            </p:column>
                            <p:column headerText="联登新用户数" style="text-align:center;">
                                <h:outputText value="#{record.newNum}"/>
                            </p:column>
                            <p:column headerText="联登新用户占比" style="text-align:center;">
                                <h:outputText value="#{record.getUserRate()}%"/>
                            </p:column>
                        </p:dataTable>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>